- [Instructor] A photodiode is basically the opposite
of a light emitting diode.
Unlike an LED, which converts electrical current
passing through it into light,
when light shines on the semiconductor junction
in a photodiode, the photodiode absorbs energy
from the light and converts it into electrical current.
The schematic symbol for a photodiode
is similar to the similar for an LED,
except that the arrow points in the other direction
to represent light shining onto the photodiode.
Physically, photodiodes come in a variety of shapes
and sizes for different applications,
ranging from small photocells
that can be used to build light detector circuits
to large solar panels that can be used to power devices.
Some Through Hole photodiode components
come in a package that looks very similar to an LED.
So be careful not to get them mixed up in your parts kit.
Like LEDs, photodiodes are polarized components,
so their orientation in the circuit matters.
The Through Hole photodiodes that look similar to LEDs
use similar features to indicate orientation.
The lead connected to the anode will be longer
than the cathode lead, and there's usually a flat section
on the cathode side of the photodiode's body.
When light shines on the photodiode,
the current it produces will flow from the cathode
to the anode, which is the opposite of the direction
the current flows through a normal forward biased diode.
Remember, photodiodes are just the opposite of LEDs.
The amount of current generated by a photodiode
will depend on the amount of light shining on it.
The more light it gets, the more current it will produce.
I can actually measure the current
produced by a photodiode using just my DMM.
It'll be a tiny amount of current,
so I'll set this DMM
to its smallest current measurement range,
which is 20 microamps.
When I connect the DMM probes to the terminals
of this photodiode, I can see that it's producing
about four and a half microamps
from the light that's currently shining on it.
If I move my hand to cast a shadow over the photodiode,
the output current drops down to less than a microamp
because the photodiode is getting less light energy
that it can convert into electricity.
And if I shine a flashlight on the photodiode
to give it more light, the current it produces will increase
to around 10 microamps.
Photodiodes are commonly used in photo detector circuits
that sense the amount of light shining on them.
These photo detectors show up in a wide range
of consumer electronic devices, including CD players,
smoke detectors, and infrared TV remotes.
I can build a very simple photo detector circuit
with just a photodiode and a resistor in series
connected to a DC voltage source.
In this configuration, the diode's cathode
is connected to the positive side of the voltage source,
so it will be reverse biased.
As a reverse biased diode, it blocks current
from the voltage source from passing through it.
But as light shines on the diode,
it will allow some of those electrons to flow through
and generate a small amount of current
that flows out of the anode down through the resistor.
According to Ohm's law,
when current flows through a resistor,
it'll create a voltage across the resistor
which we can easily measure with a multimeter,
or using the analog to digital convertor
on a microcontroller system like the Arduino platform.
So to demonstrate that, I'll use the five volt source
from an Arduino Uno microcontroller board
to reverse bias of photodiode
connected in series with a 330 kiloohm resistor.
And I'll measure the output voltage across that resistor
using analog input channel zero.
I've chosen to use a 330 kiloohm resistor here
because the amount of current
produced by the photodiode is so small,
and I need that large of a resistance
to produce a large enough voltage
for the Arduino to measure it.
You may need to use a different resistor value
based on the photodiode you're using
and the light conditions in your room.
I've written a simple Arduino program
that repeatedly reads the voltage
on analog input channel zero
and prints the voltage value to the serial port.
I've also included a conditional if/else statement
within the program to determine whether the detector circuit
is in the light or the dark
based on whether the measured voltage
is above or below a certain threshold value,
which I configured in the program.
I've included the code for this program
in the exercise files as Photodiode_Arduino_Demo.ino.
With my Arduino program running,
I can see that the light detector circuit
produces around 2.9 volts
from the ambient light in this room.
And the program says that there is light.
When I cover it with my hand to cast a shadow,
I can see how much the voltage drops,
and the program says that it's dark.
It took a bit of testing for me to determine
the voltages that my circuit would produce
in these two conditions
so I could set the voltage values in my software
to easily distinguish between light and dark.
It's possible to build a light detector circuit
with similar functionality using other types
of light sensitive components, such as a photoresistor.
And the fact that photodiodes and photoresistors
can be both be used for similar purposes
often leads to confusion between them.
But they are different components
that work in different ways.
Photodiodes produce a current
that is proportional to the amount of light shining on them,
whereas photoresistors change their resistance
depending on the amount of light shining on them.
There are lots of other light sensitive components
that can be used to build specialized light detectors,
such as photo transistors and photo multiplier tubes,
but deciding which one of those many options is best
for a specific application
is beyond the scope of this course.
To keep things simple, when you need a photo detector,
I recommend sticking with either a photoresistor
or a photodiode, because they're easy to use
and can create light detector circuits that are good enough
for most hobbyist projects.
Photoresistors can usually give you a more sensitive
measurement than photodiodes,
but the downside is that photoresistors
react much more slowly to changes.
So if you need to measure something that changes slowly,
like the ambient light in a room,
a photoresistor would be good for that.
On the other hand, if you want to measure something
that changes quickly, like a fast blinking LED,
you would be better off using a photodiode
because they're able to react to changes in light
much more quickly than photoresistors.